package com.smiletrain.activities;

import java.util.List;

import com.smiletrain.R;
import com.smiletrain.activities.base.AbstractActivity;
import com.smiletrain.base.Alarma;
import com.smiletrain.util.AdminAlarma;
import com.smiletrain.view.ItemAlarm;
import com.smiletrain.view.ListaAlarm;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.ListView;

public class AlarmasActivity extends AbstractActivity {
	/**
	 * @see android.app.Activity#onCreate(Bundle)
	 */
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.alarmas_view);
		super.setFootLayout();
		
		ListView listView = (ListView) findViewById(R.id.listView1);
		
		List<Alarma> alarmas = AdminAlarma.instance.getAlarmas();
		
		ItemAlarm[] values = new ItemAlarm[alarmas.size()];
		
		int i = 0;
		for(Alarma a : alarmas){
			values[i] = new ItemAlarm(a.getId(), a.getFecha(), a.getHora() + " Hrs");
			i++;
		}

        listView.setAdapter(new ListaAlarm(values));
        
        ImageView bRecordatorio = (ImageView) findViewById(R.id.bRecordatorio);
		
		bRecordatorio.setOnClickListener(new OnClickListener() {
        	
			@Override
			public void onClick(View v) {
				Intent intent = new Intent(AlarmasActivity.this, AddRecordatorioActivity.class);
				startActivity(intent);
			}
			
		});
		
		ImageView siguiente = (ImageView) findViewById(R.id.bSiguiente);
        
        siguiente.setOnClickListener(new OnClickListener() {
        	
			@Override
			public void onClick(View v) {
				Intent intent = new Intent(AlarmasActivity.this, PostFotosActivity.class);
				startActivity(intent);
			}
			
		});
        
	}
	
	@Override
	protected void onStart() {
		ListView listView = (ListView) findViewById(R.id.listView1);
		
		List<Alarma> alarmas = AdminAlarma.instance.getAlarmas();
		
		ItemAlarm[] values = new ItemAlarm[alarmas.size()];
		
		int i = 0;
		for(Alarma a : alarmas){
			values[i] = new ItemAlarm(a.getId(), a.getFecha(), a.getHora() + " Hrs");
			i++;
		}

        listView.setAdapter(new ListaAlarm(values));
        
        super.onStart();
	}

	@Override
	public void updateCaso() {
		
	}
	
}
